]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
windowPreview: Fix a division by zero
authorJonas Dreßler <verdre@v0yd.nl>
Fri, 19 Jun 2020 08:10:21 +0000 (10:10 +0200)
committerFlorian Müllner <florian.muellner@gmail.com>
Tue, 23 Jun 2020 15:50:03 +0000 (15:50 +0000)
When the bounding box size is 0 during allocation (which happens right
after creating a window for example), we're doing a division by zero and
end up with a NaN scale. This ends up making the childBox NaN, which
triggers an error in Clutters allocation machinery.

So fix that and fall back to a scale of 1 in case the bounding box is
empty.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1320

js/ui/windowPreview.js

index 842a4c5155971d91fd00cd521f2e90c5346776b3..b7fc5efa5a17c63b3f8ee7f6a4a78968dd485748 100644 (file)
@@ -67,8 +67,12 @@ var WindowPreviewLayout = GObject.registerClass({
     vfunc_allocate(container, box) {
         // If the scale isn't 1, we weren't allocated our preferred size
         // and have to scale the children allocations accordingly.
-        const scaleX = box.get_width() / this._boundingBox.get_width();
-        const scaleY = box.get_height() / this._boundingBox.get_height();
+        const scaleX = this._boundingBox.get_width() > 0
+            ? box.get_width() / this._boundingBox.get_width()
+            : 1;
+        const scaleY = this._boundingBox.get_height() > 0
+            ? box.get_height() / this._boundingBox.get_height()
+            : 1;
 
         const childBox = new Clutter.ActorBox();